package com.alibaba.citrus.ots.sales.plan.functions.planstrategy;

import com.alibaba.citrus.ots.common.util.SpringContextUtil;
import com.alibaba.citrus.ots.sales.plan.repository.SalesPlanStrategyRepository;
import com.alibaba.citrus.ots.sales.plan.sdo.SalesPlanStrategySDO;
import lombok.Getter;
import lombok.Setter;

public class PlanStrategyEntity {

    @Getter
    @Setter
    private SalesPlanStrategySDO salesPlanStrategySDO;

    private static SalesPlanStrategyRepository salesPlanStrategyRepository;
    static {
        salesPlanStrategyRepository = SpringContextUtil.getBean(SalesPlanStrategyRepository.class);
    }

    public static PlanStrategyEntity of(SalesPlanStrategySDO sdo) {
        PlanStrategyEntity entity = new PlanStrategyEntity();
        entity.setSalesPlanStrategySDO(sdo);
        return entity;
    }

    public String save() {
        return salesPlanStrategyRepository.save(this.salesPlanStrategySDO);
    }

    public Integer doEdit() {
        return salesPlanStrategyRepository.editSalesPlanStrategy(salesPlanStrategySDO);
    }
}
